package com.cq.service.impl;

import com.cq.mapper.AdminMapper;
import com.cq.pojo.Admin;
import com.cq.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author: 悠久的苍穹
 * @Date: 2021/1/9 20:10
 * @Description: ${description}
 * @Version: 1.0
 */
@Service
public class AdminServiceImpl implements AdminService {

    @Autowired
    AdminMapper adminMapper;

    @Override
    public Admin findAdminByPassword(String name, String password) {
        return adminMapper.findAdminByPassword(name,password);
    }

    @Override
    public Admin findAdminByPhone(String phone) {
        return adminMapper.findAdminByPhone(phone);
    }

    @Override
    public int updateAdmin(Admin admin) {
        return adminMapper.updateAdmin(admin);
    }

    @Override
    public Admin findAdminById(Integer id) {
        return adminMapper.findAdminById(id);
    }

    @Override
    public int updatePassword(String password, Integer id) {
        return adminMapper.updatePassword(password,id);
    }

    @Override
    public int getCount() {
        return adminMapper.getCount();
    }

    @Override
    public List<Admin> findAllAdmin(int page, int limit) {
        return adminMapper.findAllAdmin((page-1)*limit,limit);
    }

    @Override
    public List<Admin> findAllAdminByRoleId(int role_id, int page, int limit) {
        return adminMapper.findAllAdminByRoleId(role_id,(page-1)*limit,limit);
    }

    @Override
    public int addAdmin(Admin admin) {
        return adminMapper.addAdmin(admin);
    }

    @Override
    public Admin findAdminByName(String name) {
        return adminMapper.findAdminByName(name);
    }

    @Override
    public void deleteAdminById(int id) {
        adminMapper.deleteAdminById(id);
    }

    @Override
    public Admin findAdminByRoleId(Integer id) {
        return adminMapper.findAdminByRoleId(id);
    }
}
